<template>
	
	<view class="con">
		<CustomNavbar></CustomNavbar>
		<view class="icont">
			<view class="swiper">
				<u-swiper
					:list="bannerData"
					keyName="banner_path"
					:circular="true"
					@change="e => currentOne = e.current"
					:autoplay="true"
					height="600"
					@click="onJump()"
					>
					<view slot="indicator" class="indicator">
						<view class="indicator__dot"
							v-for="(item, index) in bannerData"
							:key="index"
							:class="[index === currentOne && 'indicator__dot--active']"
						>
						</view>
					</view>
				</u-swiper>
			</view>
			<view class="icontli" v-for="(v,i) in list.one">
				<image :src="v.img_url" mode="widthFix"></image>
			</view>
			<view class="jumpTo">
				<view class="jumpToli" @click="jumpTo(v)" v-for="(v,i) in list.brand">
					<image :src="v.brand_img" mode="widthFix"></image>
				</view>
			</view>
			<view class="icontli"  v-for="(v,i) in list.two">
				<image :src="v.img_url" mode="widthFix"></image>
			</view>
			<view class="swiper">
				<u-swiper
					:list="list.sevenTwo"
					keyName="img_url"
					@change="e => currentTwo = e.current"
					:autoplay="true"
					height="230"
					>
					<view slot="indicator" class="indicator">
						<view class="indicator__dot"
							v-for="(item, index) in list.sevenTwo"
							:key="index"
							:class="[index === currentTwo && 'indicator__dot--active']"
						>
						</view>
					</view>
				</u-swiper>
			</view>
			<view class="icontli"  v-for="(v,i) in list.three">
				<image :src="v.img_url" mode="widthFix"></image>
			</view>
			<view class="swiper">
				<u-swiper
					:list="list.sevenThree"
					keyName="img_url"
					@change="e => currentThree = e.current"
					:autoplay="true"
					height="500"
					>
					<view slot="indicator" class="indicator">
						<view class="indicator__dot"
							v-for="(item, index) in list.sevenThree"
							:key="index"
							:class="[index === currentThree && 'indicator__dot--active']"
						>
						</view>
					</view>
				</u-swiper>
			</view>
			<view class="icontli"  v-for="(v,i) in list.four">
				<image :src="v.img_url" mode="widthFix"></image>
			</view>
			<view class="swiper">
				<u-swiper
					:list="list.sevenFour"
					keyName="img_url"
					@change="e => currentFour = e.current"
					:autoplay="true"
					height="380"
					>
					<view slot="indicator" class="indicator">
						<view class="indicator__dot"
							v-for="(item, index) in list.sevenFour"
							:key="index"
							:class="[index === currentFour && 'indicator__dot--active']"
						>
						</view>
					</view>
				</u-swiper>
			</view>
			<view class="icontli"  v-for="(v,i) in list.five">
				<image :src="v.img_url" mode="widthFix"></image>
			</view>
			
		</view>
		<side-bar></side-bar>
	</view>

</template>

<script>
	import{logins,getXgjBanner,bannerIndexData} from '@/api/index.js'
	import{sceneList} from '@/api/goodsList.js'
	import sideBar from "@/components/sheet/sideBar.vue"
	import CustomNavbar from "@/components/CustomNavbar.vue"
	import {getUserInfo} from '@/api/my.js'
	export default {
		data() {
			return {
				bannerData:[],
				list:{
					
				},
				currentOne:0,
				currentTwo:0,
				currentThree:0,
				currentFour:0,
				phoneNumber:'', //客服电话
				findCoceralVal:''//搜索的值
			}
		},
		components: {
			sideBar,
			CustomNavbar
		},
		onLoad(options) {
			console.log(options)
			
			let custom = uni.getMenuButtonBoundingClientRect(); // 小程序右上角胶囊信息
			let system = uni.getSystemInfoSync(); // 获取设备信息
			this.navHeight = system.statusBarHeight + 44; // 导航栏的高度
			this.customTop = custom.top; // 胶囊按钮与顶部的距离
			this.customHeight = custom.height; // 胶囊按钮与右侧的距离
			
			if(!uni.getStorageSync('jwt')){
				this.getLogin();
			}else{
				this.gettopCate();
				
			}
			
		},
		methods: {
			hdChufa(e){
				console.log(e)
				
			},
			jumpTo(e){
				console.log(e)
				uni.navigateTo({
					url: e.jump_path+'?brand_id='+e.id
				});
			},
			//轮播图的跳转
			onJump(e){
				console.log(e)
				let url = this.bannerData[e].banner_url;
				
				if(this.bannerData[e].type_id == 3){
					uni.navigateTo({
						url: url+'?brand_id='+this.bannerData[e].choose_id
					});
				}else{
					uni.navigateTo({
						url: url+'?banner_id='+this.bannerData[e].id+'&cate_id='+this.bannerData[e].choose_id
					});
				}
				
			},
			
			
			//跳转页面
			onSearch(){
				uni.navigateTo({
					url: '/package/goodsList/indextwo'
				});
			},
			
			
		
			
			
			// 首页图片
			gettopCate(){
				getXgjBanner({}).then(res => {
					console.log(res)
					this.bannerData = res.data;
					 // this.list = res.result;
				}).catch(err => {
					uni.showToast({
						title: err.msg,
						icon: "none"
					})
				})
				bannerIndexData({}).then(res => {
					console.log(res)
					 this.list = res.data;
				}).catch(err => {
					uni.showToast({
						title: err.msg,
						icon: "none"
					})
				})
			},
			//授权登录
			getLogin(){
				uni.login({
				  provider: 'weixin',
				  success: (loginRes) => {
				    const code = loginRes.code;
					logins({"code":code}).then(res => {
						uni.setStorageSync("jwt",res.data.jwt)
						
						// this.actList = res.data
						this.gettopCate();
						// this.getBannerList();
						// this.getBannerListTwo();
						// this.topCateTwo();
						// this.getCateGoodsList();
						// this.topbrandList();
						// this.getAbout();
					}).catch(err => {
						uni.showToast({
							title: err.msg,
							icon: "none"
						})
					})
				    // 在这里可以将code发送到后端服务器进行处理
				  }
				});
			},
			getStatus(e) {
				this.isLogin = e
			},
			toDetail() {
				uni.navigateTo({
					url: "/package/info/index"
				}) 
			},
		}
	}
</script>

<style lang="scss">
	@import 'index.scss';
</style>